package cn.wolfcode.crm.query;

import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

@Setter @Getter
public class ChartQueryObject extends QueryObject{



	private String groupType="e.name";

	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date beginTime;

	@DateTimeFormat(pattern = "yyyy-MM-dd")
	private Date endTime;

	public void setEndTime(Date date){
		if(date !=null){
		Calendar calendar = Calendar.getInstance();
		calendar.setTime(date);
		calendar.set(Calendar.HOUR_OF_DAY,23);
		calendar.set(Calendar.MINUTE,59);
		calendar.set(Calendar.SECOND,59);
		this.endTime=calendar.getTime();
	}}

	public static final Map<String,String> GROUP_TYPE_MAP = new HashMap<>();

	static {
		GROUP_TYPE_MAP.put("e.name","员工");
		GROUP_TYPE_MAP.put("DATE_FORMAT(c.inputTime,'%Y')","年");
		GROUP_TYPE_MAP.put("DATE_FORMAT(c.inputTime,'%Y-%m')","月");
		GROUP_TYPE_MAP.put("DATE_FORMAT(c.inputTime,'%Y-%m-%d')","日");
	}

}
